package com.huanzhidadi.rollback.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huanzhidadi.rollback.mapper.UserMapper;
import com.huanzhidadi.rollback.model.User;
import com.huanzhidadi.rollback.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int insertWithoutTransactional(User user) {
        return userMapper.insert(user);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insertWithTransactional(User user) {
        return userMapper.insert(user);
    }
}
